Skip to main content

Send and receive an MQ message

Put a message on an IBM MQ queue, then read the reply that the system puts on another queue, and check it.

info

Before you start.

  • The connection details of an IBM MQ queue manager: host, port, queue manager, channel, and the queue names. Ask your administrator or the MQ team.
  • The queue manager must be reachable from the AGIS server.
  • A secret for the MQ password (Secrets).
  • Permissions: Build Environment, Build Collection, Update Test Case, Run Test (Permissions).
  • Direction is named from the system under test's side. Inbound means a message goes into the system (AGIS puts it). Outbound means a message comes out of the system (AGIS reads it).

Steps​

  1. Create an MQ environment. In Environments, click + New Environment and choose the protocol MQ. Enter Host / IP, Port, Queue manager, Channel, the Inbound queue and the Outbound queue, the User ID and pick the password secret. See Environments.

  2. Create a collection. Create a collection with a REST / SOAP default environment as usual, and set Default environment · MQ to your MQ environment. See Collections and cases.

  3. Add the sending case. Click Add Case, choose the MQ environment, set Direction to Inbound, give it a name and create it. The case editor opens on the Message tab, with the connection shown at the top.

  4. Fill in the message. Choose a Message type (a template fills the body) or keep None (free XML) and write your own. Enter a Correlation ID that identifies this message, for example TEST-0001, and make sure the Message body (XML) contains the same value where your system expects it. Save the case.

  5. Add the receiving case. Add a second case with the same MQ environment, and set Direction to Outbound. It must come after the sending case.

  6. Choose how to find the reply. Under Match the message by, choose Correlation ID and enter the same value as the sent message. The other choices are Any message, Message ID, and A field in the message body (path), which uses an XPath on the XML and a value.

  7. Set the wait. In Wait up to (ms), enter how long to wait for the reply (default 10000, maximum 300000). Choose After a match: Remove the message (consume it) or leave it on the queue. Only messages that arrive after the run started are considered.

  8. Add checks. On the Assertions tab, the check "Message received before the timeout" is built in and cannot be removed. Click Add response assertion to check values in the message, for example an MQ_BODY_XPATH value. See MQ cases.

  9. Publish and run. Publish and run the collection. If the collection has MQ cases, the Run tab also shows an Environment · MQ field.

Check the result​

Open the run and the receiving case. The result shows the message evidence: the sent and received message, the message ID and correlation ID, and the time. If no message arrived, it says "Nothing matched" or "The queue held no message in the window".

Common problems​

What you seeWhyWhat to do
"Nothing matched"No message with that correlation ID arrived in timeCheck the queue names, the match settings, and raise Wait up to (ms).
Connection or authorisation errors (for example MQ code 2035)The user is not allowed, or the host is unreachableCheck the User ID, the secret and the network access with your administrator.
SECRET_MISSINGThe MQ password secret is missing in the vault of the person who starts the runAdd the secret with the same name.
An Inbound case has no assertionsIt only puts a messageCheck the reply in the Outbound case.